package edu.kit.csl.pisa.datatypes;

/*
This file is part of the PISA Alignment Tool.

Copyright (C) 2013
Karlsruhe Institute of Technology
Cognitive Systems Lab (CSL)
Felix Stahlberg

PISA is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PISA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PISA. If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * This class represents a source word in an alignment. Instances of this class
 * are used for iterating through alignments on the source side.
 * 
 * @see SentenceAlignment#eachSourceWord()
 */
public class AlignmentSourceWord {

	/*
	 * Alignment data
	 */
	private short srcWordPos;
	private int srcWord;
	private byte fertility;
	
	/**
	 * Sole constructor. Initializes values such that after calling
	 * {@link #moveToNextWordPosition} the first time, we are at the
	 * first word on the first position.
	 */
	public AlignmentSourceWord() {
		srcWord = srcWordPos = fertility = -1;
	}
	
	/**
	 * Move to the next word.
	 * 
	 * @param srcWord source word on the next position
	 * @param fertility the fertility of the next word
	 */
	public void moveToNextWordPosition(int srcWord, byte fertility) {
		this.srcWord = srcWord;
		this.fertility = fertility;
		srcWordPos++;
	}
	
	/**
	 * Get the current position in the alignment on the source side.
	 * 
	 * @return the current source word position
	 */
	public short getSrcWordPos() {
		return srcWordPos;
	}

	/**
	 * Get the source word-id on the current position.
	 * 
	 * @return the source word-id of the current word in the source sentence
	 */
	public int getSrcWord() {
		return srcWord;
	}

	/**
	 * Get the fertility (on word level) of the current source word.
	 *  
	 * @return the fertility of the current source word
	 */
	public byte getFertility() {
		return fertility;
	}
}
